/**
 * 
 */
package com.dycn.posdashboard.data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author gongqiyi
 *
 */
public class Branch2MerchantMapping implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7118086436973899582L;

	private  Map<String,List<MerchantInfo>> branchMap=new HashMap<String,List<MerchantInfo>>();
	private  Map<String,MerchantInfo> merchantMap=new HashMap<String,MerchantInfo>();
	
	public  void build(List<MerchantInfo> allDatas){
		branchMap=new HashMap<String,List<MerchantInfo>>();
		merchantMap=new HashMap<String,MerchantInfo>();
		for(MerchantInfo someMerchantInfo:allDatas){
			if(branchMap.get(someMerchantInfo.getBranchNo())==null){
				branchMap.put(someMerchantInfo.getBranchNo(), new ArrayList<MerchantInfo>());
			}
			branchMap.get(someMerchantInfo.getBranchNo()).add(someMerchantInfo);
			merchantMap.put(someMerchantInfo.getTerminalMerchantNo(), someMerchantInfo);
		}
	}
	
	public  List<MerchantInfo> getMerchantInfoByBranchNo(String branchNo){
		return branchMap.get(branchNo);
	}

	public  MerchantInfo getMerchantInfoByMerchantNo(String merchantNo){
		return merchantMap.get(merchantNo);
	}

}
